package com.design.duty_chain;

public abstract class AbstractHandler implements Handler {

    public Handler nextHandler;

    public Handler getNextHandler() {
        return nextHandler;
    }

    public void setNextHandler(Handler nextHandler) {
        this.nextHandler = nextHandler;
    }

    protected abstract Integer getUserLevel();

    @Override
    public final String handlerMessage(Integer lever, String userName) {
        String result="";
        if(this.getUserLevel().equals(lever)) {
            result=this.operator(userName);
        }else{
            result=this.nextHandler.handlerMessage(lever,userName);
        }


        return result;
    }
}
